package com.loukou.lkt.lkt.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.loukou.lkt.lkt.entity.SerialNumber;

public interface SerialNumberDao extends CrudRepository<SerialNumber, Integer> {
	
	SerialNumber findByVoucherTypeAndWarehouseIdAndVoucherCodeLike(int voucherType,int warehouseId,String voucherCode);
	
	SerialNumber findByVoucherTypeAndWarehouseId(int voucherType,int warehouseId);
	
	@Modifying
	@Transactional
	@Query("update SerialNumber set voucherCode = ?3 where voucherType = ?1 and warehouseId=?2 ")
	int updateSerialNumber(int voucherType,int warehouseId,String voucherCode);
}
